-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prom conversion: Support terraform outputs #49
base: main
Are you sure you want to change the base?
Conversation
…g rules (not groups)
This stack of pull requests is managed by Graphite. Learn more about stacking. |
322f804
to
5747798
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add tests for the TF conversion logic?
require ( | ||
github.com/alecthomas/participle/v2 v2.1.0 | ||
github.com/anyascii/go v0.3.2 | ||
github.com/chronosphereio/terraform-provider-chronosphere v1.6.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(no action needed) this ends up pulling in a fair few new deps. not a huge deal, but i wonder if we should move the conversion functions out of the chronosphere
package into a subpackage
@@ -6,17 +6,17 @@ replace github.com/chronosphereio/chronoctl-core => ../ | |||
|
|||
require ( | |||
github.com/chronosphereio/chronoctl-core v0.0.0-00010101000000-000000000000 | |||
github.com/go-openapi/analysis v0.21.4 | |||
github.com/go-openapi/analysis v0.22.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updates here seem fine, just curious what they were needed for
@@ -1684,7 +1684,7 @@ func setReceiverSlugs( | |||
// each receiver has at most one target. Returned receivers also have slugs set. | |||
// The returned map indexes the original receivers names the new receivers for that name. | |||
func expandReceivers( | |||
receivers []*config.Receiver, | |||
receivers []config.Receiver, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this change?
b, err := in.MarshalBinary() | ||
if err != nil { | ||
return nil, err | ||
} | ||
var tf tfmodels.Configv1Collection | ||
err = tf.UnmarshalBinary(b) | ||
if err != nil { | ||
return nil, err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use a generic function to DRY this up?
we may be able to pass the XFromModel
function as an arg to have that handled too?
return nil, err | ||
} | ||
out.HCLID = tfid.SafeID(tf.Slug) | ||
out.ExecutionGroup = collectionTFID(out.ExecutionGroup) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BucketSlug
should use a collectionTFID
, but ExecutionGroup
is treated as a flat string, and generally isn't a reference
} | ||
tf.HCLID = tfid.SafeID(notifier.Slug) | ||
tfOut.EmailNotifiers = append(tfOut.EmailNotifiers, tf) | ||
notifierTypes[notifier.Slug] = "chronosphere_email_alert_notifier" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we avoid these hardcoded values by using .Ref()
and using .Type()
(will probably need a typecast)
https://github.com/chronosphereio/terraform-provider-chronosphere/blob/main/chronosphere/intschema/classic_dashboard.go#L54
} | ||
return tfid.LocalRef(tfid.Ref{ | ||
Type: "chronosphere_notification_policy", | ||
ID: slug.Slug(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to use a TF safe ID here?
2d73136
to
652d6f3
Compare
Adds a method for converting the outputs of prometheus/alertmanager conversion to terraform types that can be marshalled to HCL. Once
chronoctl convert
is implemented, it will output HCL if--output=hcl
is set.